import path from "path";
import HtmlWebpackPlugin from "html-webpack-plugin";

const config = {
    entry: {
        "index": "./src/index.ts",
    },
    mode: "development",
    devtool: "inline-source-map",
    plugins: [
        new HtmlWebpackPlugin({
            template: "./template/index.html",
            chunks: ["index"],
            filename: "./index.html",
        }),
    ],
    output: {
        clean: true,
        path: path.resolve(__dirname, "dist"),
        filename: "[name].js",
    },
    module: {
        rules: [
            {
                test: /\.tsx?$/,
                use: "ts-loader",
                include: [path.resolve(__dirname, "src"), path.resolve(__dirname, "demo")],
            },
            {
                test: /\.css$/i,
                use: ["style-loader", "css-loader"],
            },
            {
                test: /\.(png|svg|jpg|gif)$/,
                use: ["url-loader"],
            },

        ],
    },
    devServer: {
        open: true,
        host: "localhost",
    },
    resolve: {
        extensions: [".tsx", ".ts", ".js"],
        symlinks: false,
    },
    optimization: {},

};

const dev = process.argv.indexOf("production") < 0;
export default config;